<%@include file="/header.jsp" %>


<div id="breadcrump">
    <ul id="breadcrump-list">
        <li>&raquo; Product afbeelding wijzigen</li>
    </ul>
</div>

<c:choose>
    <c:when test="${param.success == 'true'}">
        <c:url value="/backend/ProductAdmin" var="backUrl">
            <c:param name="category_id" value="${param.category_id}" />
        </c:url>
        Product afbeelding is bijgewerkt! <a href="${backUrl}">Terug</a>
    </c:when>
    <c:when test="${product == null}">
        Product niet gevonden.
    </c:when>
    <c:when test="${product != null}">
        <c:url value="/ShowImage" var="imageUrl">
            <c:param name="id" value="${product.image.id}" />
        </c:url>
        <c:url value="/backend/ProductAdmin" var="backUrl">
            <c:param name="category_id" value="${product.category.id}" />
        </c:url>
        
        <form enctype="multipart/form-data" action="" method="POST">
            <c:choose>
                <c:when test="${product.image != null}">
                    Huidige afbeelding:<br>
                    <img src="${imageUrl}" width="150px"><br>
                    <input type="submit" name="deleteImgSubmit" value="Verwijder afbeelding"><br><br>
                </c:when>
            </c:choose>
            
            <table border="1">
                <tr>
                    <td><label for="inpImage">Afbeelding</label></td>
                    <td><input type="file" name="image" id="inpImage"><br>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="submit" name="saveImgSubmit" value="Opslaan"></td>
                </tr>
            </table>
        </form>
        <a href="${backUrl}">Terug</a>
    </c:when>
</c:choose>
                
<%@include file="/footer.jsp" %>